// import { clipboard } from '@ve/utils/clipboard'
// import { jsonToTable } from '@ve/utils/jsonToTable'

import isEmpty from 'lodash/isEmpty'
// import { Toast } from 'vant'
import { ElMessage } from 'element-plus'
// import { Toast } from 'vant'
import { translateTitle } from '@/utils/i18n'

//必须带done回调 执行完成调用
export default function pdaGetCardData({ vm, action, done, eventName }) {
  let { tabsSelect, tabsIndex } = action.extension
  let cardSelf = null
  let index = ''

  if (!isEmpty(tabsSelect.value)) {
    // 选中了选项卡
    cardSelf = vm.vuiComponents[tabsSelect.value[0]]?.self

    // 激活选项卡
    index = tabsIndex.value

    console.log('选中了选项卡', cardSelf, index)
    cardSelf.$activeFuc(index)
  } else {
    ElMessage({
      showClose: true,
      message: translateTitle('Pda.elements.请选择选项卡!'),
      type: 'error',
    })
    console.log('eventName', eventName)
    // 修改任务队列执行状态，防止下一次事件被拦截
    vm[`${eventName}IsRunning`] = false
  }

  done(null, {})
}
